package com.peoit.honeycomb.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.UUID;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.peoit.honeycomb.domain.repository.EntityRepository;

/**
 * Created by Bing.Zeng on 2015/9/23.
 */
@MappedSuperclass
public class BaseEntity implements Serializable {

	private static EntityRepository repository;

	@Id
	@Column(length = 64, nullable = false)
	private String id;

	@Temporal(TemporalType.TIMESTAMP)
	private Date createTime;

	@Temporal(TemporalType.TIMESTAMP)
	private Date updateTime;

	public BaseEntity() {
		this.id = UUID.randomUUID().toString();
		this.createTime = new Date();
		this.updateTime = new Date();
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public static EntityRepository getRepository() {
		if (repository == null) {

		}
		return repository;
	}
}
